package ipebg.mzk.provider.system.service.impl;

import ipebg.mzk.common.util.Page;
import ipebg.mzk.facade.entity.MsFile;
import ipebg.mzk.facade.system.service.MsFileService;
import ipebg.mzk.provider.system.dao.IMsFileDao;

import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service("msFileServiceImpl")
public class MsFileServiceImpl implements MsFileService {
	
	private static Log log = LogFactory.getLog(MsFileServiceImpl.class);
	
	@Resource(name="msFileDao")
	IMsFileDao msFileDao;
	
	
	
	
	@Override
	@Transactional
	public void batchSave(List<MsFile> files) throws Exception {
		try {
			msFileDao.batchSaveFiles(files);
		} catch (Exception e) {
			throw e;
		}
	}
	
	@Override
	@Transactional
	public boolean batchDeleteFiles(List<MsFile> files) throws Exception {
		try {
			msFileDao.batchDeleteFiles(files);
			return true;
		} catch (Exception e) {
			throw e;
		}
	}

	@Override
	@Transactional
	public void save(MsFile fileObj) throws Exception {
		try {
			msFileDao.save(fileObj);
		} catch (Exception e) {
			throw e;
		}
	}

	@Override
	@Transactional
	public void update(MsFile fileObj) throws Exception {
		try {
			msFileDao.update(fileObj);
		} catch (Exception e) {
			throw e;
		}
	}

	@Override
	@Transactional
	public void delete(MsFile fileObj) throws Exception {
		try {
			msFileDao.delete(fileObj);
		} catch (Exception e) {
			throw e;
		}
	}

	@Override
	@Transactional
	public List<MsFile> getAll() throws Exception {
		List<MsFile> files=null;
		try {
			files=msFileDao.getAll();
		} catch (Exception e) {
			throw e;
		}
		return files;
	}

	@Override
	@Transactional
	public Page getFiles(String realFileName, int from, int length) throws Exception {
		Page page=null;
		try {
			page=msFileDao.getFiles(realFileName, from, length);
		} catch (Exception e) {
			throw e;
		}
		return page;
	}

	@Override
	@Transactional(readOnly=true)
	public MsFile findFile(String id) throws Exception {
		 MsFile file =null;
		try {
			file =msFileDao.findFile(id);
		} catch (Exception e) {
			throw e;
		}
		return file ;
	}
}

